IE423 Project Part 3 continues from here...

C. Pointwise Defected Linen Images

In this part, 4 pointwise defected linen images are investigated. Due to their roundness, the orientation of the defect (theta) degree is insignificant. As a result of that, theta can be taken as both 0° and 90° and also the degrees between them. Hence, first two of the images will be investigated by taking the theta 0° and the rest two by taking the theta as 90° as a parameter of Gabor filter function.

C.1. Fabric3

In [1]:
library(jpeg)
library(wvtool)
In [2]:
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric3_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
 num [1:512, 1:512] 0.835 0.792 0.824 0.812 0.792 ...
In [3]:
test<-gabor.filter(img_grey,30,0,4,0,1,TRUE)

Since the pointwise property of the defect, the orientation angle doesn't effect the quality of the Gabor filter. Thus for this and the next example, the Gabor filter is applied to the image by using the parameters lamda=30, theta=0, bandwidth=4, phi=0 and asp=1. The results are displayed. The filtered image can be seen in the lower right side above. By the Gabor filter, the defect became more obvious and easier to detect.

In [4]:
str(test$filtered_img)
newimage<-test$filtered_img
 num [1:512, 1:512] 22910758 22868770 22812048 22745195 22675136 ...
In [5]:
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
  for(j in 1:16){
    m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)]) 
    s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
  }
}
In [6]:
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
In [7]:
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
In [8]:
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
  out_of_control[k]=i
  k<-k+1
  }
}
out_of_control
  1. 124
  2. 157
  3. 158
  4. 181
  5. 253
  6. 254
  7. 255
  8. 256
In [2]:
library(jpeg)
img_original3<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid3.jpg")
plot(1:512, type='n')
rasterImage(img_original3, 1, 1, 512, 512)

C.2. Fabric18

In [9]:
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric18_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
 num [1:512, 1:512] 0.565 0.529 0.584 0.573 0.471 ...
In [10]:
test<-gabor.filter(img_grey,30,0,4,0,1,TRUE)
In [11]:
str(test$filtered_img)
newimage<-test$filtered_img
 num [1:512, 1:512] 18110738 17878045 17583967 17250441 16901107 ...
In [12]:
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
  for(j in 1:16){
    m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)]) 
    s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
  }
}
In [13]:
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
In [14]:
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
  out_of_control[k]=i
  k<-k+1
  }
}
out_of_control
  1. 2
  2. 4
  3. 5
  4. 45
  5. 120
  6. 121
  7. 143
  8. 179
  9. 234
In [17]:
img_original18<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid18.jpg")
plot(1:512, type='n')
rasterImage(img_original18, 1, 1, 512, 512)

C.3. Fabric19

In [15]:
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric19_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
 num [1:512, 1:512] 0.463 0.447 0.388 0.349 0.506 ...
In [16]:
test<-gabor.filter(img_grey,30,90,4,0,1,TRUE)

Since the pointwise property of the defect, the orientation angle doesn't effect the quality of the Gabor filter. Thus for this and the next example, the Gabor filter is applied to the image by using the parameters lamda=30, theta=90, bandwidth=4, phi=0 and asp=1. The results are displayed. The filtered image can be seen in the lower right side above. By the Gabor filter, the defect became more obvious and easier to detect.

In [17]:
str(test$filtered_img)
newimage<-test$filtered_img
 num [1:512, 1:512] 14786688 14803799 14827900 14858689 14895411 ...
In [18]:
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
  for(j in 1:16){
    m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)]) 
    s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
  }
}
In [19]:
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
In [20]:
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
In [21]:
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
  out_of_control[k]=i
  k<-k+1
  }
}
out_of_control
  1. 53
  2. 97
  3. 104
  4. 113
  5. 121
  6. 129
  7. 141
  8. 144
  9. 152
  10. 157
  11. 161
  12. 173
  13. 189
  14. 205
  15. 208
  16. 209
  17. 221
  18. 237
  19. 253
  20. 254
In [25]:
img_original19<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid19.jpg")
plot(1:512, type='n')
rasterImage(img_original19, 1, 1, 512, 512)

C.4. Fabric20

In [22]:
img<-readJPEG("C:/Users/Asus/Desktop/duygu ie/423/project part 3/images/bw/pointwise/Fabric20_.jpg")
img_grey<-img[,,1]
hist(img_grey)
str(img_grey)
 num [1:512, 1:512] 0.455 0.486 0.42 0.412 0.349 ...
In [23]:
test<-gabor.filter(img_grey,30,90,4,0,1,TRUE)
In [24]:
str(test$filtered_img)
newimage<-test$filtered_img
 num [1:512, 1:512] 13406019 13392723 13382205 13374630 13370085 ...
In [25]:
m<-rep(NA)
s<-rep(NA)
for(i in 1:16){
  for(j in 1:16){
    m[(i-1)*16+j]=mean(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)]) 
    s[(i-1)*16+j]<-sd(newimage[(32*(i-1)+1):(32*(i-1)+32),(32*(j-1)+1):(32*(j-1)+32)])
  }
}
In [26]:
CL<-mean(m)
UCL<-CL+2*sd(m)
LCL<-CL-2*sd(m)
plot(m, type="l")
points(m, pch=".", col="darkred", cex=3, type = "p")
abline(CL,0, col="blue")
abline(UCL,0, col="red")
abline(LCL,0, col="red")
In [27]:
out_of_control<-rep(0)
k<-1
for(i in 1:256){
if(m[i]>UCL|m[i]<LCL){
  out_of_control[k]=i
  k<-k+1
  }
}
out_of_control
  1. 6
  2. 104
  3. 105
  4. 119
  5. 121
  6. 136
  7. 137
  8. 224
  9. 240
In [32]:
img_original20<-readJPEG("C:/Users/ipeku/Desktop/IE 423/IE423 Project Part 3/Grid images/grid20.jpg")
plot(1:512, type='n')
rasterImage(img_original20, 1, 1, 512, 512)

CONCLUSION

In this project, we were given 20 different images of linen which are defective and these defects must be detected by using some techniques and approaches. We converted the images into greyscale and we used Gabor filtering to segment textures and extract defective parts. The images were seperated into 3 groups due to its linen defect orientations in order to use the Gabor filter efficiently. These groups are formed as horizontally, vertically and pointwise defected linen images. Then, we divided the filtered images into 256 patches each have certain window size of 32x32. Since the local structures are important in our case, we concluded that performing operations on patches and constructing charts on them is important.

Throughtout the project, we observed that a perfect defect detection is almost impossible as the quantity and type of patterned images for evaluation increase. In our approach, by grouping images into vertical,horizontal and pointwise, we tried to increase the number of correct detection. In this project we only used windows of sized 32x32 however by increasing or decreasing the window size we may detect more number of defects. Also, for some cases, the patches cover only half of the defect which causes the decrease in defect detection rate. In our project, we observed that situation in image 5, that is why we had only 2 out-of-control patches on that image which are not covering the main defect in the middle of the linen image.

In conclusion, we think that identification of defect orientation is an important element of image processing and better methods can be developed by using machine learning algorithms, which needs more samples. Also, true specification of Gabor filter parameters and patch window sizes is substantial to have significant defect detection process.

REFERENCES

  • Kumar, A., and G. K. H. Pang. "Defect Detection in Textured Materials using Gabor Filters." IEEE Transactions on Industry Applications, vol. 38, no. 2, 2002, pp. 425-440.
  • Ngan, Henry Y. T., Grantham K. H. Pang, and Nelson H. C. Yung. "Automated Fabric Defect detection—A Review." Image and Vision Computing, vol. 29, no. 7, 2011, pp. 442-458.
  • Haindl, Michal, Jiří Grim, and Stanislav Mikeš. "Texture Defect Detection." vol. 4673, Springer Berlin Heidelberg, Berlin, Heidelberg, 2007.
  • Heilbronner, Renée Panozzo , “The autocorrelation function: an image processing tool for fabric analysis”, Tectonophysics, vol. 212, 1992, pp. 351-370
  • Benito, Mónica, and Daniel Peña. "Detecting Defects with Image Data." Computational Statistics and Data Analysis, vol. 51, no. 12, 2007, pp. 6395-6403.
  • Padmavathi S, Prem P, Praveenn D, “Locating Fabric Defects Using Gabor”, International Journal of Scientific Research Engineering & Technology, vol. 2, Issue 8, pp. 472-478